package com.example.demo;

import com.almasb.fxgl.app.GameApplication;
import com.almasb.fxgl.app.GameSettings;
import com.almasb.fxgl.dsl.FXGL;
import com.almasb.fxgl.entity.Entity;
import com.example.demo.Entity.Player;
import javafx.scene.input.KeyCode;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Text;
import java.util.Map;

import static com.almasb.fxgl.dsl.FXGL.*;
public class MyGame extends GameApplication {

    private Player player= new Player("李逍遥",16,100,100,10);
    @Override
    protected void initSettings(com.almasb.fxgl.app.GameSettings settings) {
        settings.setWidth(600);
        settings.setHeight(600);
        settings.setTitle("我的FXGL游戏");
        settings.setVersion("0.1");
    }
    public static void main(String[] args) {
        launch(args);
    }

    @Override
    protected void initGame() {

    }

    @Override
    protected void initGameVars(Map<String, Object> vars) {
        vars.put("playerName", player.getName());
        vars.put("playerHp",player.getHp());
    }

    @Override
    protected void initUI() {
        Text textPixels = new Text();
        textPixels.setTranslateX(50); // x = 50
        textPixels.setTranslateY(100); // y = 100

        textPixels.textProperty().bind(getWorldProperties().intProperty("playerHp").asString());

        getGameScene().addUINode(textPixels); // add to the scene graph
    }


}
